using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace DataAccess
{
    /// <summary>
    /// Controller class for ASPStateTempSessions
    /// </summary>
    [System.ComponentModel.DataObject]
    public partial class ASPStateTempSessionController
    {
        // Preload our schema..
        ASPStateTempSession thisSchemaLoad = new ASPStateTempSession();
        private string userName = String.Empty;
        protected string UserName
        {
            get
            {
				if (userName.Length == 0) 
				{
    				if (System.Web.HttpContext.Current != null)
    				{
						userName=System.Web.HttpContext.Current.User.Identity.Name;
					}
					else
					{
						userName=System.Threading.Thread.CurrentPrincipal.Identity.Name;
					}
				}
				return userName;
            }
        }
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public ASPStateTempSessionCollection FetchAll()
        {
            ASPStateTempSessionCollection coll = new ASPStateTempSessionCollection();
            Query qry = new Query(ASPStateTempSession.Schema);
            coll.LoadAndCloseReader(qry.ExecuteReader());
            return coll;
        }
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public ASPStateTempSessionCollection FetchByID(object SessionId)
        {
            ASPStateTempSessionCollection coll = new ASPStateTempSessionCollection().Where("SessionId", SessionId).Load();
            return coll;
        }
		
		[DataObjectMethod(DataObjectMethodType.Select, false)]
        public ASPStateTempSessionCollection FetchByQuery(Query qry)
        {
            ASPStateTempSessionCollection coll = new ASPStateTempSessionCollection();
            coll.LoadAndCloseReader(qry.ExecuteReader()); 
            return coll;
        }
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public bool Delete(object SessionId)
        {
            return (ASPStateTempSession.Delete(SessionId) == 1);
        }
        [DataObjectMethod(DataObjectMethodType.Delete, false)]
        public bool Destroy(object SessionId)
        {
            return (ASPStateTempSession.Destroy(SessionId) == 1);
        }
        
        
    	
	    /// <summary>
	    /// Inserts a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Insert, true)]
	    public void Insert(string SessionId,DateTime Created,DateTime Expires,DateTime LockDate,DateTime LockDateLocal,int LockCookie,int Timeout,bool Locked,byte[] SessionItemShort,byte[] SessionItemLong,int Flags)
	    {
		    ASPStateTempSession item = new ASPStateTempSession();
		    
            item.SessionId = SessionId;
            
            item.Created = Created;
            
            item.Expires = Expires;
            
            item.LockDate = LockDate;
            
            item.LockDateLocal = LockDateLocal;
            
            item.LockCookie = LockCookie;
            
            item.Timeout = Timeout;
            
            item.Locked = Locked;
            
            item.SessionItemShort = SessionItemShort;
            
            item.SessionItemLong = SessionItemLong;
            
            item.Flags = Flags;
            
	    
		    item.Save(UserName);
	    }
    	
	    /// <summary>
	    /// Updates a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
	    public void Update(string SessionId,DateTime Created,DateTime Expires,DateTime LockDate,DateTime LockDateLocal,int LockCookie,int Timeout,bool Locked,byte[] SessionItemShort,byte[] SessionItemLong,int Flags)
	    {
		    ASPStateTempSession item = new ASPStateTempSession();
	        item.MarkOld();
	        item.IsLoaded = true;
		    
			item.SessionId = SessionId;
				
			item.Created = Created;
				
			item.Expires = Expires;
				
			item.LockDate = LockDate;
				
			item.LockDateLocal = LockDateLocal;
				
			item.LockCookie = LockCookie;
				
			item.Timeout = Timeout;
				
			item.Locked = Locked;
				
			item.SessionItemShort = SessionItemShort;
				
			item.SessionItemLong = SessionItemLong;
				
			item.Flags = Flags;
				
	        item.Save(UserName);
	    }
    }
}
